Quantitative Metabarcoding

Author

Gled Guri

Published

March 13, 2025

If you end up using any of the following model please cite Guri et al., 2024 for models 1 and 2. For models 3 - 5 please cite Guri et al., 2024

This package is designed to simplify complex mathematical processes, allowing researchers, resource managers, and technicians to analyze environmental DNA (eDNA) data without needing advanced mathematical expertise. By using Bayesian inference, the package helps estsimate eDNA concentration from field samples. This package is currently in beta development, and new features and improved documentation are ongoing. Please feel free to reach out with any questions or feedback.

This package includes 5 models that can be used individually or joined within 3 frames of inferences:
1. qPCR (M1 & M2)
2. Metabarcoding (M3 & M4)
3. qPCR + Metabarcoding (M5 which jointly estimates M1-M4)

1 Directed Acyclic Graph (DAG) of the model overview

QM model overview

First things first, load the package and its dependencies.

devtools::install_github("gledguri/QM",dependencies = TRUE, force = T )
library(QM)
load_QM_packages()

You can load your data but I have included a set of data in the package to work and play with.

# data(herring_qpcr);force(herring_qpcr) #extra data to play around with
data(cod_qpcr);force(cod_qpcr)
data(metabarcoding);force(metabarcoding)

Let’s view the data

cod_qpcr
# A tibble: 403 × 7
   Well  Sample_name Species         Sample_type Ct          Plate   Std_concentration
   <chr> <chr>       <chr>           <chr>       <chr>       <chr>               <dbl>
 1 A1    Std-CH1     Clupea harengus STANDARD    20.67928886 Plate_B           1000000
 2 B1    Std-CH2     Clupea harengus STANDARD    24.28047562 Plate_B            100000
 3 C1    Std-CH3     Clupea harengus STANDARD    27.46961784 Plate_B             10000
 4 D1    Std-CH4     Clupea harengus STANDARD    30.63396072 Plate_B              1000
 5 E1    Std-CH5     Clupea harengus STANDARD    34.198452   Plate_B               100
 6 F1    Std-CH6     Clupea harengus STANDARD    36.77652359 Plate_B                10
 7 G1    Std-CH7     Clupea harengus STANDARD    39.35696793 Plate_B                 1
 8 A2    Std-CH1     Clupea harengus STANDARD    20.85572815 Plate_B           1000000
 9 B2    Std-CH2     Clupea harengus STANDARD    24.01898384 Plate_B            100000
10 C2    Std-CH3     Clupea harengus STANDARD    27.45393944 Plate_B             10000
# ℹ 393 more rows
metabarcoding
# A tibble: 10 × 93
   Species                      sp_idx ini_conc Mock_1 Mock_2 Mock_3 Mock_4 Mock_5 Mock_6 `2019629_11` `2019629_15` `2019629_16` `2019629_22` `2019629_28` `2019629_31` `2019629_32` `2019629_6` `2019629_7` `2020620_03` `2020620_04` `2020620_05` `2020620_06` `2020620_07` `2020620_08` `2020620_11` `2020620_12` `2020620_13` `2020620_14` `2020620_15` `2020620_16` `2020620_19` `2020620_20` `2020620_21` `2020620_22` `2020620_23` `2020620_24` `2020620_27` `2020620_28` `2020620_29` `2020620_30` `2020620_31` `2020620_32` `2021624_10` `2021624_11` `2021624_14` `2021624_15` `2021624_16` `2021624_17` `2021624_18` `2021624_19` `2021624_20` `2021624_21` `2021624_22` `2021624_25` `2021624_26` `2021624_27` `2021624_28` `2021624_29` `2021624_3` `2021624_30` `2021624_31` `2021624_32` `2021624_33` `2021624_36` `2021624_37` `2021624_38` `2021624_39` `2021624_4` `2021624_40` `2021624_41` `2021624_42` `2021624_43` `2021624_44` `2021624_5` `2021624_6` `2021624_7` `2021624_8` `2021624_9` `2019629_12` `2019629_13` `2019629_14` `2019629_19` `2019629_20` `2019629_21` `2019629_23` `2019629_24` `2019629_27` `2019629_29` `2019629_3` `2019629_30` `2019629_4` `2019629_5` `2019629_8`
   <chr>                         <int>    <int>  <int>  <int>  <int>  <int>  <int>  <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>       <int>       <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>       <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>       <int>        <int>        <int>        <int>        <int>        <int>       <int>       <int>       <int>       <int>       <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>        <int>       <int>        <int>       <int>       <int>       <int>
 1 Brosme brosme                     1     6022  26537  26282  55800  37606  34698  82587            0            0            0            0            0            2            0           0           6            2         1782            0            2            0            0            0            2            0            2            0            0            2            0            0            2            0            0            0            0            0            2            0            0            0            0           10            2            0            6            0            0            2            0            0            2            0            2            2            4           0           10            0            4            0            2            0            0            0           0            0            0            6            0            0           0           0           0           2           2            0            0            1            0            0            0            7            2            0            0           2            0           0           1           0
 2 Cyclopterus lumpus                2    12061  63611  38494  80634  58797  37921  95245            2            0            0            2            0            0            0           0           0            4            2            0            2            4            0            0            0            6            0            8            0            0            0            0            4            0            0            0            0            2            4            0            0            2            4            0            0            0            2            0            0            0            2            0           12            4            0           10            0           4           22            4           30            2            2           10            2         6444           0            2            0         1114            0            0           0           0           2           8           2            0            3            6            1            3            0           12            1            1            1          18        90138           2           0           4
 3 Hippoglossoides platessoides      3     6812 103953  53527  96043  83638  50442 118507         8214            0            0         6890            2            0            2       13672           4        17624        20868            0         5686        10148         6574          350            0            6        22342            4         7552        24912            0        12842        17432            4           10         9522        34610        10024        27240        22970        10798           28            6        16172            0            0         8272         8308            8        13990            8         4340       244510       360158       113176       477728       233486       25768       510300       240732       543826        63728        85020         3722        20754        40130        3822         4332        15434        99374        30014        23738           0        1580        1512        5490       13680            1        10716        67511        20325         1203            1        13598            2         7871           18       21045        14509           9           6           3
 4 Leptoclinus maculatus             4     3725 228228 124488 237519 194652 107854 256737          160            0            0         6800            0            0            0        5240           0            4          848            0         3274          746            0            0            0            0            0            2            0            0            0            0          254            0            0            0            0            0         3020         5034            0            2            2            2            0            0            0            0            0            0            2            0         1336            0            0         5584            2        2046            0           66         1024            0         2312        18044            2         1430           0          582            0          724            0            0           0         294        3372           2           0            1            5        21640            5            4            2          218            2            1            2        2016        22234        5348           4           0
 5 Mallotus villosus                 5     9816  72751  35851  94465  58157  31141  90112        70304         3100            6            4           10            0           10        1372        6580          242         2040            4          256            0            0          210         5816          436        15670        10472            2          780            4            4        26074         4454        15910         1640         7958         3552        20624         6072            2         3432         4750        26782         1502          496            4            2           14         4004           14            4        48540        10376       239346        39828        12914          12         9548        15520        98442        16534         6886         3704            6         2534          12            4           10        12658            8            6           4        7354        5094          74        3270            5           11           13            3           10            0           11           73            2            6        9830         3047       40385         860         226
 6 Maurolicus muelleri               6     7087  99815  29082 130790 120742  58762 162580            0            0            0            0            2            0            0           0           2            2            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            2            0            0            2            0            0            0            0            0            0            0            0            0            0            0            0            0            2            2           0            0            0            0            0            0            0            0            0           2            0            0            2            0            0           0           0           4           0           0            0            0            1            3            0            0            3            0            0            0           1            0           0           3           1
 7 Myoxocephalus scorpius            7     8908  75120  44139  77521  70449  48500  91900            0            0            0            2            0            0            0           0           0            6            4            0            0            2           10            0            2            2            0            2            0            2            0            0            4            0            0            2            0            0            0            2            2            2            0            4            0            2            0            0            0            2            0            0            4            2            0            2            6           2           14            4           10            0            0            2            0            4           2            2            0           18            0            0           0           0           0           2           0            0            1            2            0            0            0            2            0            0            1           6            3           2           0           0
 8 Pholis gunnellus                  8     4477  66110  36235  58501  52223  38270  75811          100          694            0         2936            2          834            0        9916           0         2446         3070            4         3306         5562         1146            0            0         2218            4         5542         3176            0            0            4          556            0            0         2428            0         9314         1448         2034            4          824         6954           14         2866            0         1702            0            2            0            2            0         1194           14            6         3068          574        2410           16         1388         2508            4         1094         8266         5300         4572           0          734            0         2678            0            0           2         830        1420        7630        1884            0            0            1            0            0            0            0            0            0            1          12            3           1           0           0
 9 Pleuronectes platessa             9     2637  41550  19983  44716  44234  27283  63749            0            0            0            0            0            0            0           0           0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0            0           0            0            0            0            0            0            0            0            0           0            0            0            0            0            0           0           0           0           0           0            0            0            0            0            0            0            0            0            0            0           0            0           0           0           0
10 Zz_Gadus morhua                  10     5942  72763  56460 111345  82212  52685 112193         8514            8         1752         4462         5630         4822        26164       78346       50714        50744        17520         2622        32848        44932         2036          272        22108            0        25250            2            0        25320        16498         1482        12430        20104         7386         3100        12350            0        14652        11836            4        22106         5912        70490         4274         8420        17494         8180            8        25790        12904           14        30104        23940        13508        65144        11634       17790        88546        15530        49048            6        32758          694          186        18264        8326        18766         4664        79992            4         5492        1652       17274        8860        4160       48536            3            6        23677            0            5            0        11638         4592         7772        36686       18466        20476       29841           8           2

2 Model 1

Before going to load and run Model 1 and 2 here’s a description of the model.
This model implements a two step model (joint model) to estimate the relationship between DNA concentration (C) and qPCR outcomes (Y and Z). The model jointly combines two compartments (eq. 1.1 - 2.3) to estimate DNA concentration using both Ct values (Y) and positive or negative qPCR amplification outcomes (Z). For detailed explanation please read Guri et al., 2024.

In short the presence (Z = 1) or absence (Z = 0) of qPCR amplification in sample \(i\) in technical replicate \(j\) is modeled as a Bernoulli random variable with the probability of amplification \(\theta_i\). The probability of amplification arises from a Poisson process with rate parameter \(\lambda\). The probability of having no amplification events is given by \(e^{-\lambda}\), and thus the probability of positive amplification is \(1-e^{-\lambda}\). We model \(\lambda\) as a function of concentration where \(\lambda = C \cdot \phi\). Hence \(\phi\) is the probability that a single target molecule in reaction will lead to a successful amplification event. In the ideal scenario when only one target molecule is in the reaction and it gets successfully amplified, \(\phi = 1\).

Additionally the second compartment models the observed Ct values (Y) in sample \(i\) in technical replicate \(j\) as random variable drawn from a Normal distribution with mean \(\mu\) and standard deviation \(\sigma\). We model \(\mu\) as a linear function of DNA concentration (C) with intercept and slope \(\beta0\) and \(\beta1\) (Equation 2.2). The standard deviation of the observed Y is an exponential function of DNA concentration with intercept and slope \(\gamma0\) and \(\gamma1\) (Equation 2.3). Note that \(\beta0\) (intercept between Ct and DNA concentration) has subscript \(_p\) meaning that is different for every plate. The reason for having a different \(\beta0\) is due to the qPCR machine being sensitive to external factors hence every qPCR run has a different \(\Delta\)Rn (normalized fluorescence signal).

\[ \begin{aligned} &\textbf{qPCR probability of detection model}\\ Z_{ij} &\sim \text{Bernoulli}(\theta_{i}) && \text{(1.1)} \\ \theta_{i} &= 1 - exp(-C_{i} \cdot \phi) && \text{(1.2)} \\ &\text{}\\ &\textbf{qPCR continuous model}\\ Y_{ij} &\sim \text{Normal}(\mu_{i}, \sigma_{i}) && \text{(2.1)} \\ \mu_{i} &= \beta0_{p} + \beta1 \cdot ln(C_{i}) && \text{(2.2)} \\ \sigma_{i} &= e^{(\gamma0 + \gamma1 \cdot ln(C_{i}))} && \text{(2.3)} \end{aligned} \]

2.1 Load the stan model

In order to run the Bayesian model, first the model needs to be loaded. All the stan model are located in the github repository under folder Stan. Loading each model takes slightly less than 1 min.

M1 <- load_model('M1')

2.2 Prepare the data to be loaded in the model.

The data should be formatted in a particular form, distinguishing the different samples and their information. Please use data_example('M1') to see the data format for required for Model 1 or use data(cod_qpcr) to load the data included in the package.

stan_data_M1 <- prep_stan_M1(
   qpcr_data = cod_qpcr %>% filter(Sample_type=="STANDARD"),
   Ct = "Ct",
   standard_concentration = "Std_concentration",
   plate_index = 'Plate')
Plate index matches the total number of plates

2.3 Run the model.

This chunk runs the Bayesian model (eq. 1.1 - 2.3) using rstan where C is the known DNA concentration from the Standard samples, Y is the observed Ct values form the qPCR machine and Z (Z = 1 for positive amplification & Z = 0 for non amplification hence Ct == ‘Undetermined’).

The output is a list containing 2 lists ([1] data list imputed into stan model and [2] stan model output). All the unknown parameters of the model (all Greek letters such as \(\phi\), \(\beta0_p\), \(\beta1\), \(\gamma0\), \(\gamma1\), \(\mu\), \(\sigma\), \(\theta\)) are in stan model output and can be extracted by using extract_qpcr_param(model_output) see below. Note that \(\beta0\) (intercept between Ct and DNA concentration) has subscript \(_p\) meaning that is different for every plate. The reason for having a different \(\beta0\) is due to the qPCR machine being sensitive to external factors hence every qPCR run has a different \(\Delta\)Rn (normalized fluorescence signal).

M1_output <- Run_Model(stan_object = M1, stan_data = stan_data_M1)

2.4 Extract outputs

Here is how you extract the important parameter of the model.

extract_qpcr_param(M1_output)
        parameter       mean     se_mean         sd       2.5%        25%        50%        75%      97.5%    n_eff      Rhat
1       logit_phi  3.2420316 0.010810820 0.91200110  1.5715169  2.5938366  3.2156153  3.8521423  5.1041729 7116.615 1.0007106
2 beta_0[Plate_B] 40.4310653 0.003062435 0.14619837 40.1416021 40.3330241 40.4333219 40.5293979 40.7190121 2279.037 1.0006413
3 beta_0[Plate_D] 40.6082936 0.003205735 0.15231180 40.3029135 40.5077600 40.6089421 40.7098604 40.9034233 2257.417 1.0006020
4 beta_0[Plate_E] 40.6065830 0.003148785 0.15261296 40.3013869 40.5053493 40.6075140 40.7079923 40.9060401 2349.074 1.0005768
5 beta_0[Plate_F] 40.7563320 0.003099993 0.14650769 40.4662319 40.6593486 40.7579603 40.8539034 41.0417027 2233.569 1.0005878
6 beta_0[Plate_G] 40.4666824 0.003046929 0.14619272 40.1729411 40.3707481 40.4693517 40.5639408 40.7573463 2302.114 1.0006100
7          beta_1 -1.4205847 0.000238786 0.01092142 -1.4421236 -1.4278951 -1.4206836 -1.4133561 -1.3988143 2091.904 1.0006730
8         gamma_0  0.7784077 0.001075718 0.08989875  0.6045856  0.7166790  0.7777105  0.8393911  0.9551911 6984.105 1.0006914
9         gamma_1 -0.2328286 0.000179802 0.01347497 -0.2583044 -0.2419845 -0.2331060 -0.2238289 -0.2060890 5616.530 0.9999822

2.5 Plot outputs

This chunk extracts the parameters (all Greek letters in eq. 1.1 - 2.3) and plots them in relation to observed values (Ct and Z). Two different plots are generated each representing the two model compartments, the probability of detection model (eq. 1.1 - 1.2) by running plot_qpcr_prob_det(M1_output), and the continuous model (eq. 2.1 - 2.3) by runningplot_qpcr_cont_mod(M1_output).

plot_qpcr_prob_det(M1_output)

plot_qpcr_cont_mod(M1_output)

plot_qpcr_curves(M1_output)

Also I made a custom function that can plot the continuous model having the plates as the facet.

plot_qpcr_cont_mod_plate_specific(M1_output)

3 Model 2

Model 2 builds on Model 1 by incorporating environmental samples (e.g., field-collected data) alongside standard samples. By sharing parameters learned from the standards (e.g., detection probabilities or Ct-concentration relationships with the known DNA concentration), it estimates the DNA concentration (C_est_log) for imputed field samples (Sample_name) with credible intervals (C_est_log_2.5%CI and C_est_log_97.5%CI). The estimated DNA concentration (C_est_log) from environmental samples can be extracted from the model output using extract_est_conc(M2_output) function see here. The mathematical notation is the same as Model 1 where 2 set of equations (eq 1.1 - 2.3) are used, one for standards and one for the unknown environmental samples where the only join information they share are the model parameters (all Greek letter).

3.1 Load the stan model

M2 <- load_model('M2')

3.2 Prepare the data to be loaded in the model.

The data should be formatted in a particular form, distinguishing the different samples and their information. Please use data_example('M2') to see the data format for required for Model 2 or use data(cod_qpcr) to load the data included in the package.

stan_data_M2 <- prep_stan_M2(
    qpcr_data = cod_qpcr,
    sample_type = "Sample_type",
    Ct = "Ct",
    sample_name_column = "Sample_name",
    standard_concentration = "Std_concentration",
    plate_index = 'Plate')
Plate index matches the total number of plates
# Run the model
M2_output <- Run_Model(stan_object = M2, stan_data = stan_data_M2)

3.3 Extract outputs

extract_qpcr_param(M2_output)
        parameter       mean     se_mean          sd       2.5%        25%        50%        75%      97.5%     n_eff      Rhat
1       logit_phi  2.9556010 0.007415575 0.938803384  1.2762092  2.2793499  2.9171052  3.5810820  4.8969930 16027.271 0.9999852
2 beta_0[Plate_B] 40.4360757 0.001742740 0.126224956 40.1895538 40.3495588 40.4362230 40.5224764 40.6829061  5245.961 1.0000969
3 beta_0[Plate_D] 40.6130081 0.001823593 0.132387591 40.3506966 40.5257019 40.6116298 40.7016212 40.8723848  5270.341 1.0001974
4 beta_0[Plate_E] 40.6120629 0.001804553 0.132830894 40.3540180 40.5218738 40.6113993 40.6997618 40.8754019  5418.246 1.0000787
5 beta_0[Plate_F] 40.7473393 0.001759935 0.128304465 40.4938553 40.6612359 40.7468494 40.8336143 41.0004357  5314.842 1.0001397
6 beta_0[Plate_G] 40.4699065 0.001751924 0.126714439 40.2207782 40.3843213 40.4684538 40.5545202 40.7215307  5231.448 1.0001915
7          beta_1 -1.4206385 0.000133059 0.009400955 -1.4391657 -1.4268731 -1.4206567 -1.4143732 -1.4023611  4991.817 1.0003046
8         gamma_0  0.6855007 0.000477799 0.056743949  0.5756948  0.6471645  0.6856107  0.7234045  0.7976237 14104.224 1.0000294
9         gamma_1 -0.2272894 0.000108144 0.012181863 -0.2498786 -0.2357952 -0.2276250 -0.2194083 -0.2024543 12688.748 0.9999070
extract_est_conc(M2_output) %>% as_tibble()
# A tibble: 84 × 5
   sample_index Sample_name C_est_log `C_est_log_2.5%CI` `C_est_log_97.5%CI`
          <dbl> <chr>           <dbl>              <dbl>               <dbl>
 1            1 2019629_11     -0.188             -1.49               0.811 
 2            2 2019629_12     -0.736             -2.72               0.644 
 3            3 2019629_13      1.36               0.309              2.24  
 4            4 2019629_14     -3.35              -7.38              -0.656 
 5            5 2019629_15     -1.35              -3.35               0.0282
 6            6 2019629_16      1.00               0.124              1.76  
 7            7 2019629_19     -0.997             -3.04               0.410 
 8            8 2019629_20     -3.18              -7.28              -0.401 
 9            9 2019629_21     -3.36              -7.38              -0.622 
10           10 2019629_22     -1.01              -2.46               0.0980
# ℹ 74 more rows

3.4 Plot outputs of Model 2

plot_qpcr_curves(M2_output)

plot_qpcr_prob_det(M2_output)

plot_qpcr_cont_mod(M2_output)

plot_qpcr_cont_mod_plate_specific(M2_output)

Here I provide a standard way of plotting the estimated DNA concentration of environmental (field) samples by putting the samples on x-axis and eDNA concentrations on y-axis. All the DNA concentrations at around \(10^{-1.3}\) and very large error bars are basically non-detects indicating that no targeted DNA was found in all technical replicate of the sample.

plot_est_conc(M2_output)

3.5 Model 3

M3 <- load_model('M3')
# Trim metabarcoding data only for mock samples
moc_dat <- metabarcoding %>% select(Species,sp_idx,ini_conc,Mock_1:Mock_6)

# # Prepare the data for going into the model
stan_data_M3 <- prep_stan_M3(
    metabarcoding_data = moc_dat,
    mock_sequencing_columns = c('Mock_1','Mock_2','Mock_3','Mock_4','Mock_5','Mock_6'),
    mock_initial_concentration = 'ini_conc',
    species_index = 'sp_idx',
    species_names = 'Species',
    number_of_PCR = 43,
    alpha_magnitude = 0.1)

# Run the model
M3_output <- Run_Model(stan_object = M3, stan_data = stan_data_M3)

3.5.1 Plot outputs of Model 3

extract_amp_efficiecy(M3_output)
                        Species sp_idx        alpha alpha_2.5%_CI alpha_97.5%_CI
1                 Brosme brosme      1 -0.014625071  -0.014737141   -0.014513716
2            Cyclopterus lumpus      2 -0.022591024  -0.022692046   -0.022490999
3  Hippoglossoides platessoides      3 -0.002313911  -0.002407170   -0.002222005
4         Leptoclinus maculatus      4  0.030800301   0.030722573    0.030878644
5             Mallotus villosus      5 -0.017323980  -0.017422689   -0.017227114
6           Maurolicus muelleri      6  0.000791310   0.000703377    0.000879898
7        Myoxocephalus scorpius      7 -0.013585638  -0.013682096   -0.013489303
8              Pholis gunnellus      8 -0.002700377  -0.002806168   -0.002596308
9         Pleuronectes platessa      9  0.002551148   0.002438054    0.002662876
10              Zz_Gadus morhua     10  0.000000000   0.000000000    0.000000000
amp_eff_output_extract(M3_output)
                        Species    Pre-PCR   Post-PCR         ALR Post-PCR_est Post-PCR_est_2.5%_CI Post-PCR_est_97.5%_CI
1                 Brosme brosme 0.08923200 0.05556938  0.01337365   0.05557098           0.05550264            0.05563849
2            Cyclopterus lumpus 0.17871590 0.07901771  0.70793133   0.07901856           0.07895890            0.07907603
3  Hippoglossoides platessoides 0.10093796 0.10672923  0.13663999   0.10673053           0.10668555            0.10677088
4         Leptoclinus maculatus 0.05519582 0.24240363 -0.46697893   0.24240248           0.24246219            0.24235272
5             Mallotus villosus 0.14545023 0.08065732  0.50196793   0.08065673           0.08060385            0.08070443
6           Maurolicus muelleri 0.10501282 0.12690236  0.17621634   0.12690111           0.12687668            0.12693097
7        Myoxocephalus scorpius 0.13199579 0.08596141  0.40490397   0.08596042           0.08591238            0.08600930
8              Pholis gunnellus 0.06633870 0.06898988 -0.28309260   0.06898966           0.06892343            0.06905184
9         Pleuronectes platessa 0.03907419 0.05093104 -0.81240387   0.05093045           0.05086558            0.05099315
10              Zz_Gadus morhua 0.08804659 0.10283804  0.00000000   0.10283908           0.10320879            0.10247219
plot_amp_eff(M3_output)

3.5.2 Run Model 4

M4 <- load_model('M4')
# Get column names for mock samples and environmental samples
mock_columns <- metabarcoding %>% select(Mock_1:Mock_6) %>% names()
sample_columns <- metabarcoding %>% select(-all_of(mock_columns),-Species,-sp_idx,-ini_conc) %>% names()

# Prepare the data for going into the model
stan_data_M4 <- prep_stan_M4(
    metabarcoding_data = metabarcoding,
    mock_sequencing_columns = mock_columns,
    sample_sequencing_columns = sample_columns,
    mock_initial_concentration = 'ini_conc',
    species_index = 'sp_idx',
    species_names = 'Species',
    number_of_PCR = 43,
    alpha_magnitude = 0.1)
Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
ℹ Please use `all_of()` or `any_of()` instead.
  # Was:
  data %>% select(mock_columns)

  # Now:
  data %>% select(all_of(mock_columns))

See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
M4_output <- Run_Model(stan_object = M4, stan_data = stan_data_M4)

3.5.3 Plot outputs of Model 4

extract_amp_efficiecy(M4_output)
                        Species sp_idx        alpha alpha_2.5%_CI alpha_97.5%_CI
1                 Brosme brosme      1 -0.014636392  -0.014747256   -0.014526431
2            Cyclopterus lumpus      2 -0.022601022  -0.022700125   -0.022503478
3  Hippoglossoides platessoides      3 -0.002322756  -0.002414040   -0.002229570
4         Leptoclinus maculatus      4  0.030791072   0.030714079    0.030868943
5             Mallotus villosus      5 -0.017332767  -0.017430149   -0.017233565
6           Maurolicus muelleri      6  0.000781456   0.000693299    0.000869383
7        Myoxocephalus scorpius      7 -0.013595035  -0.013691535   -0.013499084
8              Pholis gunnellus      8 -0.002710033  -0.002813677   -0.002607119
9         Pleuronectes platessa      9  0.002539016   0.002423267    0.002653068
10              Zz_Gadus morhua     10  0.000000000   0.000000000    0.000000000
amp_eff_output_extract(M4_output)
                        Species    Pre-PCR   Post-PCR         ALR Post-PCR_est Post-PCR_est_2.5%_CI Post-PCR_est_97.5%_CI
1                 Brosme brosme 0.08923200 0.05556938  0.01337365   0.05556460           0.05549748            0.05562912
2            Cyclopterus lumpus 0.17871590 0.07901771  0.70793133   0.07901398           0.07895847            0.07906351
3  Hippoglossoides platessoides 0.10093796 0.10672923  0.13663999   0.10672964           0.10669052            0.10677653
4         Leptoclinus maculatus 0.05519582 0.24240363 -0.46697893   0.24239645           0.24245654            0.24234329
5             Mallotus villosus 0.14545023 0.08065732  0.50196793   0.08065626           0.08060555            0.08071257
6           Maurolicus muelleri 0.10501282 0.12690236  0.17621634   0.12689455           0.12686509            0.12692159
7        Myoxocephalus scorpius 0.13199579 0.08596141  0.40490397   0.08595767           0.08590688            0.08600565
8              Pholis gunnellus 0.06633870 0.06898988 -0.28309260   0.06898668           0.06892475            0.06904586
9         Pleuronectes platessa 0.03907419 0.05093104 -0.81240387   0.05092283           0.05085064            0.05099093
10              Zz_Gadus morhua 0.08804659 0.10283804  0.00000000   0.10287735           0.10324409            0.10251095
plot_amp_eff(M4_output)

extract_ini_prop(M4_output)
                        Species   2019629_11  2019629_12   2019629_13   2019629_14   2019629_15   2019629_16   2019629_19   2019629_20   2019629_21   2019629_22   2019629_23   2019629_24   2019629_27   2019629_28   2019629_29    2019629_3   2019629_30   2019629_31   2019629_32    2019629_4    2019629_5    2019629_6    2019629_7    2019629_8   2020620_03   2020620_04   2020620_05   2020620_06   2020620_07   2020620_08   2020620_11   2020620_12   2020620_13   2020620_14   2020620_15   2020620_16   2020620_19   2020620_20   2020620_21   2020620_22   2020620_23   2020620_24   2020620_27   2020620_28   2020620_29   2020620_30   2020620_31   2020620_32   2021624_10   2021624_11   2021624_14   2021624_15   2021624_16   2021624_17   2021624_18   2021624_19   2021624_20   2021624_21   2021624_22   2021624_25   2021624_26   2021624_27   2021624_28   2021624_29    2021624_3   2021624_30   2021624_31   2021624_32   2021624_33   2021624_36   2021624_37   2021624_38   2021624_39    2021624_4   2021624_40   2021624_41   2021624_42   2021624_43   2021624_44    2021624_5    2021624_6    2021624_7    2021624_8    2021624_9
1                 Brosme brosme 1.436481e-06 0.002156286 3.294122e-06 1.692193e-05 6.019691e-06 9.964831e-05 4.430620e-07 2.640718e-05 0.0009263065 1.165373e-05 4.760814e-04 7.246519e-04 1.355024e-05 3.764879e-05 7.966002e-06 5.575558e-05 9.379822e-07 5.971426e-04 1.052135e-05 2.378802e-06 6.635255e-04 3.051903e-06 1.696942e-04 4.350866e-05 4.885910e-05 6.440922e-02 6.869951e-05 8.004091e-05 4.804331e-06 1.682701e-05 1.139315e-04 1.037081e-04 3.456328e-06 4.258936e-05 9.966373e-07 5.973548e-07 6.514420e-05 1.486576e-05 1.127429e-05 3.994927e-05 8.906296e-06 5.590734e-06 9.604847e-06 3.684102e-06 4.459105e-07 3.862146e-05 4.536846e-06 2.701839e-06 9.204635e-06 9.126187e-06 1.275554e-04 3.215952e-04 2.480568e-05 3.820439e-04 1.352351e-05 0.0009471825 7.163651e-05 1.918621e-05 1.133013e-05 8.843575e-06 6.195514e-07 5.428661e-06 5.226139e-06 2.380073e-05 5.088836e-06 2.758452e-05 8.219258e-07 8.496439e-06 3.860610e-07 2.491275e-05 5.411018e-06 3.805322e-06 2.935882e-06 1.803491e-05 1.104836e-05 9.775372e-06 4.920330e-05 9.511396e-07 6.986054e-06 1.052397e-04 6.997907e-06 9.839932e-06 1.779451e-04 4.943701e-05
2            Cyclopterus lumpus 2.934267e-05 0.002738524 5.568131e-04 1.470003e-04 7.400355e-06 1.359022e-04 6.009515e-05 4.860187e-03 0.0010873126 2.785114e-04 1.155635e-03 4.881735e-04 1.406489e-04 4.959158e-05 6.840568e-05 7.442749e-04 8.298196e-01 4.689724e-05 1.387641e-05 4.287265e-05 3.073499e-05 3.988359e-06 6.227362e-06 1.866031e-02 1.384589e-04 9.445322e-05 9.235576e-05 1.130939e-04 1.628478e-04 2.307174e-05 1.351212e-04 1.065585e-05 4.145912e-03 4.342313e-06 6.924322e-04 7.899352e-07 6.747311e-06 2.119574e-05 1.455608e-05 1.142496e-04 1.182106e-05 7.132059e-06 1.267095e-05 4.966287e-06 1.305582e-04 1.114309e-04 6.060113e-06 3.547991e-06 1.643067e-04 4.224563e-04 2.971475e-06 2.510089e-05 3.127399e-05 1.700557e-04 1.767379e-05 0.0011629105 7.549048e-06 3.753280e-04 1.357741e-05 7.700338e-05 2.279839e-05 4.972354e-07 3.810432e-05 1.070832e-06 2.029923e-04 8.579397e-05 3.217133e-05 9.136439e-05 3.912518e-05 3.465750e-05 9.536978e-04 1.542688e-04 1.881766e-01 2.423966e-05 2.017016e-04 1.275780e-05 1.322137e-02 1.143927e-06 8.915812e-06 1.394810e-04 9.723552e-06 2.035451e-04 1.074483e-03 6.943007e-05
3  Hippoglossoides platessoides 5.471799e-02 0.056280231 9.969710e-01 7.167479e-01 3.909051e-06 6.619718e-05 9.995509e-01 9.768581e-01 0.5512836955 4.427300e-01 5.608206e-01 4.289948e-04 5.279947e-01 3.629376e-04 5.351881e-04 3.688767e-01 5.585413e-02 2.295774e-05 8.069393e-05 8.401441e-05 3.326357e-03 1.387640e-01 6.692966e-05 5.617771e-03 2.649435e-01 4.442812e-01 4.750481e-05 1.419412e-01 1.791171e-01 6.850648e-01 3.518314e-01 4.909072e-06 1.738827e-03 2.976005e-01 1.353646e-04 7.003391e-01 5.051508e-01 9.920241e-06 9.048397e-01 2.205442e-01 1.441302e-04 2.635927e-04 5.312869e-01 5.677520e-01 3.816035e-01 3.320669e-01 4.731812e-01 9.989114e-01 1.012767e-03 2.700014e-04 1.233833e-01 1.227520e-05 1.557325e-05 3.199794e-01 5.287735e-01 0.1843343912 3.111095e-01 6.629355e-04 9.958849e-01 6.682752e-01 8.967267e-01 1.945244e-01 7.741321e-01 8.672159e-01 5.746299e-01 8.382852e-01 8.422516e-01 6.982763e-01 6.689608e-01 6.567063e-01 1.538965e-01 7.884076e-01 4.900130e-01 3.357981e-01 1.950076e-01 7.846322e-01 4.931723e-01 9.994431e-01 8.266118e-01 6.923418e-05 4.915405e-02 7.030768e-02 3.196318e-01 2.080331e-01
4         Leptoclinus maculatus 2.562260e-04 0.014757007 1.024096e-04 5.531674e-02 1.478562e-06 2.021164e-05 5.247087e-05 6.969570e-04 0.4392703037 1.052220e-01 2.162928e-03 1.072284e-04 1.567459e-05 7.290823e-06 1.428447e-05 8.507147e-03 2.060845e-02 7.243131e-06 1.962289e-06 1.222433e-02 5.240413e-04 1.280563e-02 8.445503e-07 1.320295e-05 1.430968e-05 4.345083e-03 1.476506e-05 1.968078e-02 3.168663e-03 3.334013e-06 2.296202e-05 1.475844e-06 1.161958e-06 5.832054e-07 1.498790e-05 2.210714e-07 9.318938e-07 3.050639e-06 2.132424e-06 7.731654e-04 1.692277e-06 1.060434e-06 1.925598e-06 7.198324e-07 1.428561e-07 8.863324e-03 2.496865e-02 7.226909e-07 1.719488e-05 2.143015e-05 3.687831e-06 3.846390e-06 4.717746e-06 1.645505e-06 2.578263e-06 0.0002356239 1.000019e-06 3.993305e-05 2.587854e-06 8.788964e-04 1.167619e-07 7.281678e-08 2.178389e-03 1.735416e-06 1.098171e-02 8.916347e-08 5.541430e-05 3.164452e-04 9.908607e-08 4.298602e-03 1.796291e-01 1.623045e-05 4.202522e-03 3.607396e-06 6.307659e-03 1.881013e-06 8.649454e-04 2.553414e-07 1.258163e-06 2.096331e-05 2.201721e-03 3.775252e-02 2.676897e-05 7.517549e-07
5             Mallotus villosus 8.930054e-01 0.789700444 1.846903e-03 2.592288e-04 8.926120e-01 6.833113e-03 2.230498e-04 1.464384e-02 0.0009882301 4.626825e-04 8.469063e-04 3.221897e-02 2.347868e-04 3.632418e-03 3.332407e-04 3.285334e-01 2.236257e-02 3.977161e-05 7.916807e-04 7.312244e-01 9.903591e-01 2.655017e-02 2.146355e-01 9.720898e-01 6.927872e-03 8.279006e-02 3.001833e-03 1.216761e-02 5.325185e-06 1.884183e-05 4.023340e-01 3.565830e-01 2.672251e-01 3.979614e-01 7.790915e-01 2.477312e-04 3.014387e-02 4.882453e-04 5.029078e-04 6.290156e-01 3.182077e-01 8.192630e-01 1.744497e-01 2.489192e-01 2.577529e-01 4.793676e-01 2.385454e-01 2.702492e-04 2.386456e-01 4.214276e-01 3.896389e-01 2.968212e-01 1.103177e-01 2.821601e-04 2.238391e-04 0.6322037337 1.697903e-01 2.241662e-03 1.549755e-03 2.529740e-01 4.926961e-02 7.844539e-01 1.230627e-01 9.145699e-02 4.997051e-04 2.990775e-02 1.035383e-01 2.410246e-01 3.309119e-01 1.014006e-01 2.919894e-01 4.086661e-04 5.898758e-02 1.971881e-03 3.271489e-04 9.364796e-04 1.197826e-01 4.712272e-04 3.836133e-04 4.712939e-03 4.361835e-01 4.516938e-01 8.166801e-03 9.480009e-02
6           Maurolicus muelleri 8.085166e-07 0.001451795 2.007503e-06 8.881290e-06 3.613133e-06 5.948800e-05 1.037224e-04 1.729349e-05 0.0007374808 7.113258e-06 1.028285e-04 2.480905e-05 7.824981e-06 3.205927e-04 4.621612e-06 1.451627e-05 5.443049e-07 2.145305e-05 5.962937e-06 1.360420e-06 1.367855e-03 1.718242e-06 2.910726e-05 1.222422e-03 2.533685e-05 2.883094e-06 4.148098e-05 3.660557e-06 2.743719e-06 9.668737e-06 6.398131e-05 4.410213e-06 2.333921e-06 1.854738e-06 6.508842e-07 4.531541e-07 2.937217e-06 8.978467e-06 6.287250e-06 1.629072e-06 5.022368e-06 3.164625e-06 5.734951e-06 2.131425e-06 3.043203e-07 2.016727e-05 2.664826e-06 1.770207e-06 6.047850e-05 5.478707e-06 1.247775e-06 1.068081e-05 1.399283e-05 5.198067e-06 7.778469e-06 0.0006274441 3.128841e-06 1.110475e-05 6.698799e-06 4.010670e-07 3.395241e-07 2.315492e-07 2.763663e-06 6.108551e-06 3.048811e-06 2.788267e-07 4.642631e-07 1.953953e-07 2.258133e-07 1.117462e-06 3.306311e-06 2.253101e-06 1.644782e-06 1.446940e-04 6.317973e-06 5.883300e-06 8.510890e-06 6.179859e-07 3.889641e-06 6.260413e-05 4.104272e-06 1.561138e-04 6.244047e-06 2.314536e-06
7        Myoxocephalus scorpius 1.366553e-06 0.002131933 9.520166e-05 3.254468e-05 5.885329e-06 9.831180e-05 4.266950e-07 2.638376e-05 0.0009302458 1.895561e-04 1.248540e-04 4.365188e-05 1.370022e-05 3.663184e-05 4.711062e-05 1.652125e-04 1.776787e-05 3.559934e-05 1.030189e-05 2.893407e-05 2.353645e-05 2.798649e-06 4.403052e-06 4.540668e-05 1.429012e-04 1.319224e-04 6.721808e-05 6.215826e-06 5.453943e-05 1.639841e-03 1.021554e-04 9.908421e-05 7.639831e-04 3.169400e-06 9.652972e-05 6.429851e-07 6.188690e-05 1.472728e-05 1.093032e-05 7.795224e-05 8.934527e-06 5.422818e-06 1.622314e-04 3.554656e-06 4.358938e-07 2.643990e-06 6.202365e-05 2.317929e-04 1.103912e-04 8.841413e-06 4.813552e-05 1.906488e-05 3.474727e-04 8.798001e-06 1.332230e-05 0.0009789218 6.866655e-05 1.873451e-05 1.038328e-05 1.714857e-05 7.619292e-06 3.742509e-07 5.100506e-06 3.484463e-05 6.770960e-05 3.699259e-05 2.165848e-05 2.055825e-05 3.824056e-07 1.936464e-06 1.182803e-04 3.581460e-06 7.560806e-05 2.618963e-04 1.372004e-04 9.220764e-06 1.436914e-04 9.584575e-07 6.569091e-06 9.926247e-05 7.011700e-06 9.317905e-06 1.737591e-04 4.131705e-06
8              Pholis gunnellus 6.756678e-04 0.001596001 2.315727e-06 1.037517e-05 1.064730e-01 6.381181e-05 3.338280e-07 1.879544e-05 0.0007708107 1.917689e-01 5.785913e-06 2.871097e-05 8.993893e-06 3.704380e-04 2.951225e-05 2.097610e-04 1.114446e-05 1.626321e-01 6.834819e-06 9.280659e-06 1.614717e-05 1.023294e-01 2.910803e-06 3.168494e-05 3.738184e-02 6.645159e-02 1.609657e-03 8.392026e-02 9.982797e-02 1.214306e-01 7.301113e-05 4.948233e-06 7.260380e-01 5.230779e-05 2.199009e-01 2.994008e-01 3.198574e-06 9.682394e-06 2.690569e-04 7.150132e-03 5.779505e-06 3.647411e-06 1.376906e-01 2.366435e-06 3.604997e-01 1.794652e-02 4.259610e-02 3.283280e-04 3.053453e-02 3.290249e-01 1.073202e-04 3.020946e-01 1.624380e-05 6.692903e-02 8.801060e-06 0.0394513416 3.532347e-06 1.627741e-04 7.510179e-06 3.316751e-03 3.491044e-05 1.016211e-05 5.054027e-03 2.166945e-03 5.463897e-02 2.653407e-05 4.936322e-03 3.274578e-03 3.764261e-05 8.585981e-03 3.475029e-01 2.046813e-01 5.675015e-02 1.229510e-05 3.357628e-02 6.123038e-06 1.351036e-02 6.668741e-07 4.286361e-06 1.228055e-03 2.624623e-02 6.708922e-02 4.516663e-01 2.912796e-02
9         Pleuronectes platessa 7.556538e-07 0.001309919 2.040151e-06 1.440851e-06 3.431956e-06 5.286230e-05 3.003229e-07 1.642843e-05 0.0007139647 6.534765e-06 4.886097e-06 2.354765e-05 7.674199e-06 2.091504e-05 4.194158e-06 2.223622e-06 4.818242e-07 2.032146e-05 5.673853e-06 1.265254e-06 1.359991e-05 1.586776e-06 2.464381e-06 3.014403e-05 2.254871e-06 2.679666e-06 3.912296e-05 3.534859e-06 2.550696e-06 9.208072e-06 6.035578e-05 4.165427e-06 2.295646e-06 1.737225e-06 6.070253e-07 4.387344e-07 2.634662e-06 8.361990e-06 5.918569e-06 1.474186e-06 4.792448e-06 2.961101e-06 5.414657e-06 1.920125e-06 3.032990e-07 1.472635e-06 2.509949e-06 1.711016e-06 4.555233e-06 4.930107e-06 1.169124e-06 1.083489e-05 1.283694e-05 4.927070e-06 7.190116e-06 0.0005799496 3.010503e-06 1.013666e-05 6.458029e-06 3.720573e-07 3.274169e-07 2.101439e-07 2.489932e-07 4.217454e-07 2.831685e-06 2.540624e-07 4.296495e-07 1.891243e-07 2.403421e-07 1.070903e-06 2.927844e-06 2.233441e-06 1.592440e-06 1.017077e-05 5.886642e-06 5.221581e-06 7.819996e-07 5.907624e-07 3.610222e-06 5.808539e-05 3.941963e-06 5.297276e-06 5.724951e-06 2.215840e-06
10              Zz_Gadus morhua 5.131101e-02 0.127877858 4.180264e-04 2.274590e-01 8.832572e-04 9.925705e-01 8.220422e-06 2.835651e-03 0.0032916495 2.593231e-01 4.342995e-01 9.659113e-01 4.715625e-01 9.951615e-01 9.989555e-01 2.928911e-01 7.132437e-02 8.365766e-01 9.990725e-01 2.563811e-01 3.675120e-03 7.195376e-01 7.850819e-01 2.245786e-03 6.903746e-01 3.374909e-01 9.950174e-01 7.420836e-01 7.176535e-01 1.917837e-01 2.452630e-01 6.431836e-01 7.896994e-05 3.043315e-01 6.609428e-05 9.238186e-06 4.645618e-01 9.994210e-01 9.433721e-02 1.422816e-01 6.816013e-01 1.804445e-01 1.563753e-01 1.833095e-01 1.165847e-05 1.615813e-01 2.206309e-01 2.477663e-04 7.294410e-01 2.488053e-01 4.866857e-01 4.006808e-01 8.892153e-01 6.122367e-01 4.709318e-01 0.1394785011 5.189417e-01 9.964582e-01 2.506750e-03 7.445141e-02 5.393693e-02 2.100463e-02 9.552138e-02 3.909216e-02 3.589680e-01 1.316296e-01 4.916284e-02 5.698719e-02 4.925240e-05 2.289449e-01 2.589852e-02 6.320077e-03 2.017883e-01 6.617551e-01 7.644192e-01 2.143805e-01 3.592462e-01 8.053146e-05 1.729691e-01 9.935041e-01 4.861828e-01 3.727727e-01 2.190702e-01 6.679106e-01
bar_plot_est_ini_prop(M4_output)

heatmap_plot_est_ini_prop(M4_output)

3.5.4 Run Model 5

M5 <- load_model('M5')
mock_columns <- metabarcoding %>% select(Mock_1:Mock_6) %>% names()
sample_columns <- metabarcoding %>% select(-all_of(mock_columns),-Species,-sp_idx,-ini_conc) %>% names()

# qpcr <- qpcr %>% filter(qpcr$Sample_name%in%sample_columns|qpcr$Sample_type=='STANDARD')

stan_data_M5 <- prep_stan_M5(
    qpcr_data = cod_qpcr,
    sample_type = "Sample_type",
    Ct = "Ct",
    sample_name_column = "Sample_name",
    standard_concentration = "Std_concentration",
    plate_index = 'Plate',
    metabarcoding_data = metabarcoding,
    mock_sequencing_columns = mock_columns,
    sample_sequencing_columns = sample_columns,
    mock_initial_concentration = 'ini_conc',
    species_index = 'sp_idx',
    species_names = 'Species',
    number_of_PCR = 43,
    alpha_magnitude = 0.1)

M5_output <- Run_Model(stan_object = M5, stan_data = stan_data_M5,
                                             treedepth = 12,iterations = 2000,warmup = 1000)

3.5.5 Plot outputs of Model 5

extract_amp_efficiecy(M5_output)
                        Species sp_idx        alpha alpha_2.5%_CI alpha_97.5%_CI
1                 Brosme brosme      1 -0.014633033  -0.014743773   -0.014524401
2            Cyclopterus lumpus      2 -0.022596908  -0.022697019   -0.022500249
3  Hippoglossoides platessoides      3 -0.002318003  -0.002409488   -0.002223638
4         Leptoclinus maculatus      4  0.030795430   0.030718880    0.030875571
5             Mallotus villosus      5 -0.017328018  -0.017428274   -0.017227128
6           Maurolicus muelleri      6  0.000787270   0.000699654    0.000876171
7        Myoxocephalus scorpius      7 -0.013590374  -0.013684852   -0.013495963
8              Pholis gunnellus      8 -0.002705424  -0.002809444   -0.002605435
9         Pleuronectes platessa      9  0.002544418   0.002434489    0.002652491
10              Zz_Gadus morhua     10  0.000000000   0.000000000    0.000000000
amp_eff_output_extract(M5_output)
                        Species    Pre-PCR   Post-PCR         ALR Post-PCR_est Post-PCR_est_2.5%_CI Post-PCR_est_97.5%_CI
1                 Brosme brosme 0.08923200 0.05556938  0.01337365   0.05556261           0.05549510            0.05562358
2            Cyclopterus lumpus 0.17871590 0.07901771  0.70793133   0.07901373           0.07895379            0.07905972
3  Hippoglossoides platessoides 0.10093796 0.10672923  0.13663999   0.10673223           0.10669084            0.10678382
4         Leptoclinus maculatus 0.05519582 0.24240363 -0.46697893   0.24239821           0.24245986            0.24236709
5             Mallotus villosus 0.14545023 0.08065732  0.50196793   0.08065820           0.08059652            0.08071983
6           Maurolicus muelleri 0.10501282 0.12690236  0.17621634   0.12690341           0.12687530            0.12693492
7        Myoxocephalus scorpius 0.13199579 0.08596141  0.40490397   0.08595941           0.08591501            0.08600113
8              Pholis gunnellus 0.06633870 0.06898988 -0.28309260   0.06898792           0.06892401            0.06903796
9         Pleuronectes platessa 0.03907419 0.05093104 -0.81240387   0.05092548           0.05086537            0.05098014
10              Zz_Gadus morhua 0.08804659 0.10283804  0.00000000   0.10285881           0.10322419            0.10249181
plot_amp_eff(M5_output)

extract_ini_prop(M5_output)
                        Species   2019629_11   2019629_12   2019629_13   2019629_14   2019629_15   2019629_16   2019629_19   2019629_20   2019629_21   2019629_22   2019629_23   2019629_24   2019629_27   2019629_28   2019629_29    2019629_3   2019629_30   2019629_31   2019629_32    2019629_4    2019629_5    2019629_6    2019629_7    2019629_8   2020620_03   2020620_04   2020620_05   2020620_06   2020620_07   2020620_08   2020620_11   2020620_12   2020620_13   2020620_14   2020620_15   2020620_16   2020620_19   2020620_20   2020620_21   2020620_22   2020620_23   2020620_24   2020620_27   2020620_28   2020620_29   2020620_30   2020620_31   2020620_32   2021624_10   2021624_11   2021624_14   2021624_15   2021624_16   2021624_17   2021624_18   2021624_19   2021624_20   2021624_21   2021624_22   2021624_25   2021624_26   2021624_27   2021624_28   2021624_29    2021624_3   2021624_30   2021624_31   2021624_32   2021624_33   2021624_36   2021624_37   2021624_38   2021624_39    2021624_4   2021624_40   2021624_41   2021624_42   2021624_43   2021624_44    2021624_5    2021624_6    2021624_7    2021624_8    2021624_9
1                 Brosme brosme 9.370422e-07 0.0012270382 1.062821e-06 1.932065e-05 3.523233e-06 0.0010789333 3.399834e-07 1.930742e-05 0.0009662509 1.072297e-05 7.890300e-04 0.0046141731 1.665335e-05 1.969604e-04 7.993447e-05 7.105224e-05 7.669336e-07 2.411247e-03 1.631780e-04 2.220521e-06 6.532215e-04 5.578907e-06 6.063287e-04 2.240990e-05 1.324948e-04 9.329920e-02 0.0007065722 2.659387e-04 8.847779e-06 1.469136e-05 7.578723e-05 2.254429e-04 2.643446e-06 5.552050e-05 1.406373e-06 8.910627e-07 1.077842e-04 1.312277e-04 8.517745e-06 4.315317e-05 1.575927e-05 4.302965e-06 6.416377e-06 3.078772e-06 7.993447e-07 4.244085e-05 4.386522e-06 1.240955e-06 1.637594e-05 4.249725e-06 2.164087e-04 4.811113e-04 9.679448e-05 7.744619e-04 1.022501e-05 2.629010e-04 1.302470e-04 0.0005659082 3.477395e-06 9.186005e-06 3.365544e-07 5.318302e-06 5.602321e-06 2.434516e-05 4.241188e-06 3.098780e-05 5.945881e-07 8.662600e-06 1.986132e-07 2.967297e-05 4.767890e-06 2.482427e-06 2.210239e-06 2.430432e-05 2.423260e-05 7.912814e-06 7.067739e-05 4.105624e-07 5.407563e-06 0.0020280913 7.299378e-06 5.920886e-06 2.119791e-04 1.309517e-04
2            Cyclopterus lumpus 2.895860e-05 0.0013162517 5.356437e-04 1.780164e-04 4.410903e-06 0.0012868595 5.833422e-05 4.805253e-03 0.0009783835 3.354656e-04 1.958618e-03 0.0028904227 2.208117e-04 2.373486e-04 9.688245e-04 9.990146e-04 8.800564e-01 1.278904e-04 2.309620e-04 5.229123e-05 2.446173e-05 7.948457e-06 1.567366e-05 1.820102e-02 3.931686e-04 1.285991e-04 0.0008810918 3.769614e-04 4.857616e-04 1.967802e-05 1.107937e-04 1.669753e-05 4.086451e-03 4.087974e-06 6.927907e-04 1.012378e-06 8.009244e-06 1.808476e-04 1.118497e-05 1.276208e-04 2.009756e-05 5.527154e-06 9.366162e-06 4.022674e-06 1.392849e-04 1.241865e-04 5.412404e-06 1.464603e-06 5.324791e-04 5.275815e-04 3.851229e-06 1.628939e-05 1.200591e-04 3.426947e-04 1.431496e-05 2.953401e-04 9.399826e-06 0.0227165721 4.565430e-06 8.147718e-05 2.318477e-05 3.379831e-07 4.121649e-05 6.447913e-07 2.996641e-04 9.687645e-05 3.280867e-05 9.612876e-05 3.700113e-05 4.107183e-05 9.590191e-04 1.513939e-04 2.316716e-01 3.119597e-05 6.723971e-04 9.689338e-06 1.931263e-02 4.564936e-07 6.918156e-06 0.0027744981 9.673867e-06 2.952669e-04 1.339088e-03 1.799050e-04
3  Hippoglossoides platessoides 5.738746e-02 0.0612632747 9.974318e-01 8.796779e-01 2.905315e-06 0.0006670843 9.995554e-01 9.781371e-01 0.5503569941 5.610706e-01 9.481397e-01 0.0027673971 9.097541e-01 2.490723e-03 8.624958e-03 4.948681e-01 5.921843e-02 6.307948e-05 2.240106e-03 1.067252e-04 3.311234e-03 4.515168e-01 2.350499e-04 5.572431e-03 7.707527e-01 6.438330e-01 0.0004519471 5.060325e-01 5.555128e-01 8.109069e-01 4.508425e-01 7.674110e-06 1.739604e-03 4.092417e-01 1.352725e-04 7.001512e-01 8.733006e-01 8.291997e-05 9.806057e-01 2.466609e-01 3.736009e-04 3.142772e-04 6.195696e-01 6.733869e-01 3.815490e-01 3.782958e-01 5.709753e-01 9.991728e-01 3.510938e-03 3.436218e-04 2.110430e-01 8.425655e-06 6.079597e-05 6.620323e-01 9.879033e-01 2.123971e-01 5.920614e-01 0.0427997308 9.983461e-01 7.136114e-01 9.463197e-01 1.984037e-01 8.387888e-01 9.004745e-01 8.856904e-01 9.515963e-01 8.818935e-01 7.391752e-01 6.689608e-01 8.135665e-01 1.558532e-01 7.923676e-01 6.032727e-01 9.552191e-01 6.840961e-01 9.724624e-01 7.208701e-01 9.995215e-01 9.734033e-01 0.0014488138 9.320603e-02 1.114615e-01 4.070886e-01 5.972898e-01
4         Leptoclinus maculatus 2.684468e-04 0.0155046957 1.001828e-04 6.790564e-02 1.004434e-06 0.0002283258 5.211115e-05 6.943108e-04 0.4403799240 1.333088e-01 3.655475e-03 0.0006836349 2.523388e-05 3.733072e-05 2.213220e-04 1.141068e-02 2.185245e-02 1.994311e-05 3.517815e-05 1.560825e-02 5.213578e-04 4.166598e-02 2.243351e-06 7.940592e-06 4.002685e-05 6.298777e-03 0.0001514528 7.017549e-02 9.827881e-03 3.109260e-06 1.808940e-05 2.430005e-06 1.002168e-06 6.111981e-07 1.525143e-05 2.838610e-07 1.153635e-06 2.714157e-05 1.804515e-06 8.647052e-04 3.171486e-06 8.788124e-07 1.474464e-06 5.802610e-07 2.120298e-07 1.009213e-02 3.014093e-02 4.088913e-07 5.513131e-05 2.559969e-05 6.063697e-06 2.824455e-06 1.994006e-05 2.529106e-06 2.205652e-06 8.586447e-05 1.376149e-06 0.0023738091 1.063432e-06 9.387641e-04 7.290759e-08 5.038796e-08 2.360593e-03 1.692659e-06 1.693413e-02 7.479928e-08 5.793606e-05 3.349656e-04 5.334683e-08 5.327832e-03 1.819071e-01 1.543965e-05 5.174301e-03 5.011284e-06 2.212936e-02 1.696697e-06 1.263650e-03 1.179559e-07 1.112041e-06 0.0005454005 4.175022e-03 5.986833e-02 3.078340e-05 1.369926e-06
5             Mallotus villosus 9.367553e-01 0.8892635786 1.823778e-03 3.172007e-04 8.930903e-01 0.1388265931 2.240104e-04 1.452892e-02 0.0009315574 5.787971e-04 1.414462e-03 0.2172738197 3.860824e-04 2.599303e-02 5.321443e-03 4.407502e-01 2.371364e-02 1.069567e-04 2.320119e-02 9.333823e-01 9.917201e-01 8.642390e-02 7.798421e-01 9.745331e-01 2.014462e-02 1.199783e-01 0.0504765601 4.340260e-02 1.006435e-05 1.600192e-05 5.152227e-01 8.203901e-01 2.671763e-01 5.472659e-01 7.790183e-01 2.527342e-04 5.208710e-02 6.146004e-03 5.329303e-04 7.036060e-01 8.415845e-01 9.818001e-01 2.033924e-01 2.951994e-01 2.577482e-01 5.461593e-01 2.878967e-01 2.512866e-04 8.277488e-01 5.593365e-01 6.663248e-01 4.909110e-01 7.375966e-01 5.746305e-04 3.799073e-04 7.400042e-01 3.231094e-01 0.1456083106 1.508158e-03 2.701612e-01 5.198212e-02 8.000884e-01 1.333179e-01 9.496362e-02 7.635573e-04 3.394004e-02 1.083989e-01 2.551558e-01 3.309578e-01 1.255785e-01 2.957806e-01 4.019706e-04 7.261069e-02 5.493990e-03 1.121960e-03 1.155810e-03 1.750370e-01 4.671888e-04 4.458243e-04 0.2740050185 8.275914e-01 7.158002e-01 1.037670e-02 2.724059e-01
6           Maurolicus muelleri 5.487109e-07 0.0008379247 7.807324e-07 1.035670e-05 2.671587e-06 0.0006320952 1.036588e-04 1.461109e-05 0.0007118002 6.440870e-06 1.660038e-04 0.0001149690 9.684841e-06 2.188850e-03 4.923985e-05 1.827595e-05 4.550145e-07 6.122703e-05 1.010181e-04 1.290653e-06 1.344833e-03 3.429307e-06 1.008871e-04 1.138245e-03 6.956862e-05 2.763093e-06 0.0004072884 7.600254e-06 5.438234e-06 8.954462e-06 4.735952e-05 7.302411e-06 1.838735e-06 1.858513e-06 8.244226e-07 5.973296e-07 3.596564e-06 7.434366e-05 4.565112e-06 1.562061e-06 9.655360e-06 2.570794e-06 4.390534e-06 1.760700e-06 4.735021e-07 2.249384e-05 2.513072e-06 7.662522e-07 1.959348e-04 2.564494e-06 1.549059e-06 7.788346e-06 4.933599e-05 8.446009e-06 5.906894e-06 1.703985e-04 4.091337e-06 0.0003279045 2.573337e-06 3.041945e-07 1.952227e-07 1.426490e-07 2.945848e-06 5.983304e-06 2.203995e-06 2.360001e-07 3.203141e-07 1.281824e-07 1.223866e-07 1.085581e-06 2.749507e-06 1.452308e-06 1.263427e-06 3.668341e-04 1.382600e-05 4.435746e-06 1.208029e-05 2.753678e-07 3.381469e-06 0.0013641610 4.292061e-06 2.364619e-04 3.856071e-06 3.922241e-06
7        Myoxocephalus scorpius 9.638470e-07 0.0011441244 8.072958e-05 3.822554e-05 3.656929e-06 0.0010379847 3.313730e-07 2.094577e-05 0.0008961755 2.382773e-04 1.955953e-04 0.0001893071 1.525297e-05 1.888072e-04 6.771804e-04 2.178996e-04 1.858788e-05 9.448624e-05 1.634652e-04 3.625531e-05 2.041112e-05 5.183793e-06 1.117951e-05 2.148133e-05 4.072956e-04 1.873645e-04 0.0006811976 1.213896e-05 1.595711e-04 1.920973e-03 8.534407e-05 2.143049e-04 7.669074e-04 3.011833e-06 1.002693e-04 7.778789e-07 1.022529e-04 1.336395e-04 7.933168e-06 8.665627e-05 1.447603e-05 3.913599e-06 1.825679e-04 3.037833e-06 7.042089e-07 2.282088e-06 7.242594e-05 2.179726e-04 3.550906e-04 4.004546e-06 8.029878e-05 1.176878e-05 2.187806e-03 1.326386e-05 1.019169e-05 2.648786e-04 1.239177e-04 0.0005310360 3.614624e-06 1.787879e-05 7.540245e-06 2.407692e-07 5.382162e-06 3.574000e-05 9.640651e-05 4.159513e-05 2.211275e-05 2.139736e-05 1.720433e-07 1.689916e-06 1.165810e-04 2.510794e-06 9.194238e-05 6.879193e-04 4.486728e-04 7.819167e-06 2.105029e-04 4.046302e-07 5.378330e-06 0.0021812749 6.698418e-06 5.905140e-06 1.979119e-04 6.137984e-06
8              Pholis gunnellus 7.057603e-04 0.0009234066 7.797937e-07 1.169306e-05 1.066323e-01 0.0006705392 2.689443e-07 1.507635e-05 0.0007911684 2.431750e-01 6.292252e-06 0.0001306328 1.061732e-05 2.522894e-03 4.186083e-04 2.780785e-04 1.168659e-05 7.025432e-01 1.116167e-04 1.098281e-05 1.450170e-05 3.330334e-01 7.857181e-06 1.679704e-05 1.087364e-01 9.629812e-02 0.0273577299 2.993311e-01 3.095444e-01 1.437089e-01 5.541468e-05 8.152282e-06 7.261728e-01 7.090832e-05 2.198607e-01 2.995750e-01 3.879052e-06 9.031253e-05 2.863633e-04 7.988403e-03 9.986779e-06 2.933682e-06 1.606947e-01 1.932094e-06 3.605200e-01 2.044847e-02 5.139966e-02 3.213749e-04 1.058330e-01 4.367299e-01 1.826696e-04 4.996816e-01 6.343891e-05 1.384362e-01 6.877347e-06 4.203028e-02 4.445089e-06 0.0096688133 2.649664e-06 3.542650e-03 3.638453e-05 1.008866e-05 5.477809e-03 2.252467e-03 8.424944e-02 2.982320e-05 5.168377e-03 3.465568e-03 3.645363e-05 1.063935e-02 3.518910e-01 2.057538e-01 6.984525e-02 1.736703e-05 1.176966e-01 4.621093e-06 1.975750e-02 2.865969e-07 3.749759e-06 0.0673803534 4.978773e-02 1.063276e-01 5.753764e-01 8.360997e-02
9         Pleuronectes platessa 5.412224e-07 0.0007764265 7.712266e-07 1.329400e-06 2.469794e-06 0.0005981732 2.354578e-07 1.316406e-05 0.0007134289 6.080236e-06 5.292804e-06 0.0001066994 9.031411e-06 1.034180e-04 4.392757e-05 2.161920e-06 3.952876e-07 5.357796e-05 9.414195e-05 1.188990e-06 1.142248e-05 3.032152e-06 6.529586e-06 1.504428e-05 3.948835e-06 2.588597e-06 0.0003926715 7.057413e-06 5.243011e-06 7.935202e-06 4.460898e-05 7.217241e-06 1.807570e-06 1.767812e-06 8.254053e-07 5.745285e-07 2.957669e-06 7.639472e-05 4.403405e-06 1.330922e-06 8.465341e-06 2.469838e-06 3.586037e-06 1.762089e-06 4.581038e-07 1.256728e-06 2.390425e-06 8.060150e-07 8.835293e-06 2.566664e-06 1.534596e-06 7.511719e-06 5.068535e-05 7.742630e-06 5.706246e-06 1.771183e-04 4.181950e-06 0.0003219009 2.387885e-06 2.853604e-07 1.953911e-07 1.356861e-07 2.110233e-07 2.709018e-07 2.374325e-06 2.257440e-07 3.063518e-07 1.150272e-07 1.208748e-07 9.963016e-07 2.738221e-06 1.448838e-06 1.206708e-06 1.357691e-05 1.304058e-05 4.288163e-06 8.341770e-07 2.615387e-07 3.098805e-06 0.0013746677 4.176173e-06 3.084384e-06 3.339580e-06 3.330044e-06
10              Zz_Gadus morhua 4.851115e-03 0.0277432789 2.450738e-05 5.184028e-02 2.567335e-04 0.8549734117 5.282309e-06 1.751332e-03 0.0032743171 6.126987e-02 4.366955e-02 0.7712289441 8.955257e-02 9.660406e-01 9.835946e-01 5.138459e-02 1.512721e-02 2.945184e-01 9.736591e-01 5.079851e-02 2.378411e-03 8.733474e-02 2.191721e-01 4.715522e-04 9.931975e-02 3.997132e-02 0.9184934886 8.038864e-02 1.244400e-01 4.339286e-02 3.349740e-02 1.791207e-01 5.065366e-05 4.335465e-02 1.743410e-04 1.692684e-05 7.438270e-02 9.930572e-01 1.853657e-02 4.061970e-02 1.579603e-01 1.786306e-02 1.613556e-02 3.139756e-02 4.082402e-05 4.481167e-02 5.950028e-02 3.187054e-05 6.174343e-02 3.023412e-03 1.221398e-01 8.871673e-03 2.597545e-01 1.978078e-01 1.166139e-02 4.311925e-03 8.455154e-02 0.7750860145 1.254349e-04 1.163685e-02 1.630273e-03 1.491514e-03 1.999954e-02 2.240709e-03 1.195760e-02 1.426386e-02 4.425114e-03 1.742043e-03 7.311775e-06 4.481332e-02 1.348221e-02 1.301939e-03 1.732883e-02 3.814067e-02 1.737838e-01 2.634132e-02 6.346499e-02 9.079440e-06 2.612179e-02 0.6468977208 2.520771e-02 5.995720e-03 5.371355e-03 4.636868e-02
bar_plot_est_ini_prop(M5_output)

heatmap_plot_est_ini_prop(M5_output)

plot_est_ini_conc(M5_output)

Guri et al., 2024 that are used in this script.